﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace stuManage
{
    public partial class teaIndex : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"];
            string strConn = "server=localhost;port=3306;user id=root;password=lxy1756431734;database=student; pooling=true;";
            MySqlConnection conn = new MySqlConnection(strConn);
            conn.Open();//链接数据库  
            DataSet ds = new DataSet();
            string sql = "select name,department from teacher_inf where id = '"+id+"'";
            MySqlCommand com = new MySqlCommand(sql, conn);
            MySqlDataReader dr = com.ExecuteReader();
            dr.Read();
                string name = dr["name"].ToString();
                string department=dr["department"].ToString();

            string HTML = "<br/><p> 职工号：" + id+"<br/>姓名："+name+"<br/>学院："+department+"</p>";
            information.InnerHtml = HTML;

            string commandString = "select tea_id,course_inf.id as couId,course_inf.name as couName,count(stu_id) as num from course_inf, tea_course, stu_course where tea_id = '" + id + "' and course_inf.id = tea_course.course_id and course_inf.id = stu_course.course_id group by course_inf.id";

            SqlDataSource1.SelectCommand = commandString;   //指定查询的命令
            GridView1.DataSourceID = SqlDataSource1.ID;     //将数据源绑定到GridView上
            GridView1.DataBind();

        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            e.Row.Cells[0].Visible = false;
        }

        }
}